/*
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 *
 * This file is part of Harmattan SmashMiner OpenGL game application.
 * 
 * Harmattan SmashMiner OpenGL Example Application version 1.0.0
 *  
 * Latest update: 15.4.2011
 *
 * The Harmattan SmashMiner OpenGL example application demonstrates how to use 
 * the OpenGL ES in Harmattan devices.
 *
 * This example is provided as a starting point for 3rd party
 * developers (you) to ease the implementation of OpenGL based 
 * games. Ideas, parts of code or methodologies that this
 * example application uses can be freely used without restrictions.
 *
 * See file README.txt how to build and compile this example application
 * in the Harmattan SDK environment. 
 * 
 * See file INSTALL.txt to find out what is required to run this
 * application and how to install the application to the device or
 * alternatively in QEMU-emulator.
 *
 * The LICENSE.txt file explains the license this software is provided
 * with. A copy of the same license is included in this source file.
 * 
 */

/*
 * Copyright (C) 2011 by Nokia Corporation.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

import Qt 4.7

// Help content to the controls help view for the page 1
Rectangle {
    id: controlsPage1
    color: "black"

    // Grid with 2 columns for control helps. Column 1 for image and column 2 for text.
    Grid {
        id: controlsGrid

        property int imageColumnWidth: controlsPage1.width * 0.25
        property int textColumnWidth: controlsPage1.width * 0.50

        // 3 * 0.05 + 2 * 0.425 = 1.000
        property int gridSpacing: controlsPage1.height * 0.05
        property int rowHeight: controlsPage1.height * 0.425

        columns: 2

        anchors {
            fill: parent
            margins: gridSpacing
        }

        spacing: gridSpacing

        // NOTE : the total lengths of the both animations are the same,
        // and they are phased so that either one of them are active.

        // Animation item for the device tilt
        Item {
            id: tiltAnim

            // the original image sizes are 800x600
            // -> height = width * 0.75

            width: controlsGrid.imageColumnWidth
            height: controlsGrid.rowHeight

            Image {
                id: tilt01
                anchors.fill: parent
                source: "pics/tiltAnim01.jpg"
                visible: false
            }

            Image {
                id: tilt02
                anchors.fill: parent
                source: "pics/tiltAnim02.jpg"
                visible: false
            }

            Image {
                id: tilt03
                anchors.fill: parent
                source: "pics/tiltAnim03.jpg"
                visible: false
            }

            Image {
                id: tilt04
                anchors.fill: parent
                source: "pics/tiltAnim04.jpg"
                visible: false
            }

            Image {
                id: tilt05
                anchors.fill: parent
                source: "pics/tiltAnim05.jpg"
                visible: false
            }

            Image {
                id: tilt06
                anchors.fill: parent
                source: "pics/tiltAnim06.jpg"
                visible: false
            }

            Image {
                id: tilt07
                anchors.fill: parent
                source: "pics/tiltAnim07.jpg"
                visible: false
            }

            Image {
                id: tilt08
                anchors.fill: parent
                source: "pics/tiltAnim08.jpg"
                visible: false
            }

            Image {
                id: tilt09
                anchors.fill: parent
                source: "pics/tiltAnim09.jpg"
                visible: false
            }

            Image {
                id: tilt10
                anchors.fill: parent
                source: "pics/tiltAnim10.jpg"
                visible: false
            }

            Image {
                id: tilt11
                anchors.fill: parent
                source: "pics/tiltAnim11.jpg"
                visible: false
            }

            Image {
                id: tilt12
                anchors.fill: parent
                source: "pics/tiltAnim12.jpg"
                visible: false
            }

            Image {
                id: tilt13
                anchors.fill: parent
                source: "pics/tiltAnim13.jpg"
                visible: false
            }

            Image {
                id: tilt14
                anchors.fill: parent
                source: "pics/tiltAnim14.jpg"
                visible: false
            }

            Image {
                id: tilt15
                anchors.fill: parent
                source: "pics/tiltAnim15.jpg"
                visible: false
            }

            Image {
                id: tilt16
                anchors.fill: parent
                source: "pics/tiltAnim16.jpg"
                visible: false
            }

            Image {
                id: tilt17
                anchors.fill: parent
                source: "pics/tiltAnim17.jpg"
                visible: false
            }

            Image {
                id: tilt18
                anchors.fill: parent
                source: "pics/tiltAnim18.jpg"
                visible: false
            }

            Image {
                id: tilt19
                anchors.fill: parent
                source: "pics/tiltAnim19.jpg"
                visible: false
            }

            Image {
                id: tilt20
                anchors.fill: parent
                source: "pics/tiltAnim20.jpg"
                visible: false
            }

            Image {
                id: tilt21
                anchors.fill: parent
                source: "pics/tiltAnim21.jpg"
                visible: false
            }

            Image {
                id: tilt22
                anchors.fill: parent
                source: "pics/tiltAnim22.jpg"
                visible: false
            }

            Image {
                id: tilt23
                anchors.fill: parent
                source: "pics/tiltAnim23.jpg"
                visible: false
            }

            SequentialAnimation {
                running: controlsPage1.visible
                loops: Animation.Infinite

                PropertyAction { target: tilt01; property: "visible"; value: true }
                PauseAnimation { duration: 1500 }
                PropertyAction { target: tilt01; property: "visible"; value: false }
                PropertyAction { target: tilt02; property: "visible"; value: true }
                PauseAnimation { duration: 300 }
                PropertyAction { target: tilt02; property: "visible"; value: false }
                PropertyAction { target: tilt03; property: "visible"; value: true }
                PauseAnimation { duration: 200 }
                PropertyAction { target: tilt03; property: "visible"; value: false }
                PropertyAction { target: tilt04; property: "visible"; value: true }
                PauseAnimation { duration: 100 }    // x-tilted
                PropertyAction { target: tilt04; property: "visible"; value: false }
                PropertyAction { target: tilt05; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt05; property: "visible"; value: false }
                PropertyAction { target: tilt06; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt06; property: "visible"; value: false }
                PropertyAction { target: tilt07; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt07; property: "visible"; value: false }
                PropertyAction { target: tilt08; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt08; property: "visible"; value: false }
                PropertyAction { target: tilt09; property: "visible"; value: true }
                PauseAnimation { duration: 100 }    // x-tilted
                PropertyAction { target: tilt09; property: "visible"; value: false }
                PropertyAction { target: tilt10; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt10; property: "visible"; value: false }
                PropertyAction { target: tilt11; property: "visible"; value: true }
                PauseAnimation { duration: 200 }
                PropertyAction { target: tilt11; property: "visible"; value: false }
                PropertyAction { target: tilt12; property: "visible"; value: true }
                PauseAnimation { duration: 300 }    // levelled
                PropertyAction { target: tilt12; property: "visible"; value: false }
                PropertyAction { target: tilt13; property: "visible"; value: true }
                PauseAnimation { duration: 200 }
                PropertyAction { target: tilt13; property: "visible"; value: false }
                PropertyAction { target: tilt14; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt14; property: "visible"; value: false }
                PropertyAction { target: tilt15; property: "visible"; value: true }
                PauseAnimation { duration: 100 }    // y-tilted
                PropertyAction { target: tilt15; property: "visible"; value: false }
                PropertyAction { target: tilt16; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt16; property: "visible"; value: false }
                PropertyAction { target: tilt17; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt17; property: "visible"; value: false }
                PropertyAction { target: tilt18; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt18; property: "visible"; value: false }
                PropertyAction { target: tilt19; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: tilt19; property: "visible"; value: false }
                PropertyAction { target: tilt20; property: "visible"; value: true }
                PauseAnimation { duration: 100 }    // y-tilted
                PropertyAction { target: tilt20; property: "visible"; value: false }
                PropertyAction { target: tilt21; property: "visible"; value: true }
                PauseAnimation { duration: 200 }
                PropertyAction { target: tilt21; property: "visible"; value: false }
                PropertyAction { target: tilt22; property: "visible"; value: true }
                PauseAnimation { duration: 300 }
                PropertyAction { target: tilt22; property: "visible"; value: false }
                PropertyAction { target: tilt23; property: "visible"; value: true }
                PauseAnimation { duration: 1500 }
                PropertyAction { target: tilt23; property: "visible"; value: false }
            }
        }

        // Explanation text for tilting
        Item {
            width: controlsGrid.textColumnWidth
            height: controlsGrid.rowHeight
            Text {
                text: qsTr("Tilt the device to steer the Miner.");
                color: "white"
                font.pointSize: 18
                anchors.verticalCenter: parent.verticalCenter
            }
        }

        // Animation item for the device shake
        Item {
            id: shakeAnim

            // the original image sizes are 800x600
            // -> height = width * 0.75

            width: controlsGrid.imageColumnWidth
            height: controlsGrid.rowHeight

            Image {
                id: shake01
                anchors.fill: parent
                source: "pics/shakeAnim01.jpg"
                visible: false
            }

            Image {
                id: shake02
                anchors.fill: parent
                source: "pics/shakeAnim02.jpg"
                visible: false
            }

            Image {
                id: shake03
                anchors.fill: parent
                source: "pics/shakeAnim03.jpg"
                visible: false
            }

            Image {
                id: shake04
                anchors.fill: parent
                source: "pics/shakeAnim04.jpg"
                visible: false
            }

            Image {
                id: shake05
                anchors.fill: parent
                source: "pics/shakeAnim05.jpg"
                visible: false
            }

            Image {
                id: shake06
                anchors.fill: parent
                source: "pics/shakeAnim06.jpg"
                visible: false
            }

            Image {
                id: shake07
                anchors.fill: parent
                source: "pics/shakeAnim07.jpg"
                visible: false
            }

            Image {
                id: shake08
                anchors.fill: parent
                source: "pics/shakeAnim08.jpg"
                visible: false
            }

            Image {
                id: shake09
                anchors.fill: parent
                source: "pics/shakeAnim09.jpg"
                visible: false
            }

            Image {
                id: shake10
                anchors.fill: parent
                source: "pics/shakeAnim10.jpg"
                visible: false
            }

            Image {
                id: shake11
                anchors.fill: parent
                source: "pics/shakeAnim11.jpg"
                visible: false
            }

            Image {
                id: shake12
                anchors.fill: parent
                source: "pics/shakeAnim12.jpg"
                visible: false
            }

            Image {
                id: shake13
                anchors.fill: parent
                source: "pics/shakeAnim13.jpg"
                visible: false
            }

            Image {
                id: shake14
                anchors.fill: parent
                source: "pics/shakeAnim14.jpg"
                visible: false
            }

            Image {
                id: shake15
                anchors.fill: parent
                source: "pics/shakeAnim15.jpg"
                visible: false
            }

            Image {
                id: shake16
                anchors.fill: parent
                source: "pics/shakeAnim16.jpg"
                visible: false
            }

            Image {
                id: shake17
                anchors.fill: parent
                source: "pics/shakeAnim17.jpg"
                visible: false
            }

            Image {
                id: shake18
                anchors.fill: parent
                source: "pics/shakeAnim18.jpg"
                visible: false
            }

            Image {
                id: shake19
                anchors.fill: parent
                source: "pics/shakeAnim19.jpg"
                visible: false
            }

            Image {
                id: shake20
                anchors.fill: parent
                source: "pics/shakeAnim20.jpg"
                visible: false
            }

            Image {
                id: shake21
                anchors.fill: parent
                source: "pics/shakeAnim21.jpg"
                visible: false
            }

            SequentialAnimation {
                running: controlsPage1.visible
                loops: Animation.Infinite

                PropertyAction { target: shake11; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake11; property: "visible"; value: false }
                PropertyAction { target: shake12; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake12; property: "visible"; value: false }
                PropertyAction { target: shake13; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake13; property: "visible"; value: false }
                PropertyAction { target: shake14; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake14; property: "visible"; value: false }
                PropertyAction { target: shake15; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake15; property: "visible"; value: false }
                PropertyAction { target: shake16; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake16; property: "visible"; value: false }
                PropertyAction { target: shake17; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake17; property: "visible"; value: false }
                PropertyAction { target: shake18; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake18; property: "visible"; value: false }
                PropertyAction { target: shake19; property: "visible"; value: true }
                PauseAnimation { duration: 200 }
                PropertyAction { target: shake19; property: "visible"; value: false }
                PropertyAction { target: shake20; property: "visible"; value: true }
                PauseAnimation { duration: 300 }
                PropertyAction { target: shake20; property: "visible"; value: false }
                PropertyAction { target: shake21; property: "visible"; value: true }
                PauseAnimation { duration: 1800 }
                PropertyAction { target: shake21; property: "visible"; value: false }

                PropertyAction { target: shake01; property: "visible"; value: true }
                PauseAnimation { duration: 1800 }
                PropertyAction { target: shake01; property: "visible"; value: false }
                PropertyAction { target: shake02; property: "visible"; value: true }
                PauseAnimation { duration: 300 }
                PropertyAction { target: shake02; property: "visible"; value: false }
                PropertyAction { target: shake03; property: "visible"; value: true }
                PauseAnimation { duration: 200 }
                PropertyAction { target: shake03; property: "visible"; value: false }
                PropertyAction { target: shake04; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake04; property: "visible"; value: false }
                PropertyAction { target: shake05; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake05; property: "visible"; value: false }
                PropertyAction { target: shake06; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake06; property: "visible"; value: false }
                PropertyAction { target: shake07; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake07; property: "visible"; value: false }
                PropertyAction { target: shake08; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake08; property: "visible"; value: false }
                PropertyAction { target: shake09; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake09; property: "visible"; value: false }
                PropertyAction { target: shake10; property: "visible"; value: true }
                PauseAnimation { duration: 100 }
                PropertyAction { target: shake10; property: "visible"; value: false }
            }
        }

        // Explanation text for shaking
        Item {
            width: controlsGrid.textColumnWidth
            height: controlsGrid.rowHeight
            Text {
                text: qsTr("Shake the device to start a HyperJump.");
                color: "white"
                font.pointSize: 18
                anchors.verticalCenter: parent.verticalCenter
            }
        }
    }
}
